
package com.shop.cloud.mall.admin.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.shop.cloud.common.core.util.R;
import com.shop.cloud.common.log.annotation.SysLog;
import com.shop.cloud.mall.common.entity.ShopDepositConfig;
import com.shop.cloud.mall.admin.service.ShopDepositConfigService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

/**
 * 店铺保证金设置
 *
 * @author
 * @date 2023-11-28 11:15:11
 */
@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("/shopdepositconfig")
@Tag(description = "shopdepositconfig", name = "店铺保证金设置管理")
public class ShopDepositConfigController {

    private final ShopDepositConfigService shopDepositConfigService;

    /**
     * 店铺保证金设置查询
     * @return R
     */
    @Operation(summary = "店铺保证金设置查询")
    @GetMapping()
    public R get() {
        return R.ok(shopDepositConfigService.getOne(Wrappers.emptyWrapper()));
    }

    /**
     * 店铺保证金设置修改
     * @param shopDepositConfig 店铺保证金设置
     * @return R
     */
    @Operation(summary = "店铺保证金设置修改")
    @SysLog("修改店铺保证金设置")
    @PutMapping
    @PreAuthorize("@ato.hasAuthority('mall:shopdepositconfig:edit')")
    public R updateById(@RequestBody ShopDepositConfig shopDepositConfig) {
        shopDepositConfigService.saveOrUpdate(shopDepositConfig);
        return R.ok(shopDepositConfig);
    }

}
